package com.zx.web.service.impl;

import com.zx.bean.Goods;
import com.zx.bean.GoodsType;
import com.zx.bean.PageBean;
import com.zx.web.dao.GoodsDao;
import com.zx.web.dao.impl.GoodsDaoImpl;
import com.zx.web.service.GoodsService;

import java.util.List;

/**
 * @author 章鑫
 * @version V1.0
 * @Project 2022-09-05
 * @Package com.zx.web.service.impl
 * @Description:
 * @Date 2022/9/14 15:18
 */
public class GoodsServiceImpl implements GoodsService {
    GoodsDao dao = new GoodsDaoImpl();
    @Override
    public PageBean<Goods> findGoodByTypeIdPage(int pageNum, int pageSize, int typeId) {
        PageBean<Goods> pageBean = new PageBean<>();
        pageBean.setPageNum(pageNum);
        pageBean.setPageSize(pageSize);

        //获取总条数，存入pageBean
        long totalCount = dao.findTotalCount(typeId);
        pageBean.setTotalCount(totalCount);
        //获取数据列表，存入pageBean
        List<Goods> data = dao.findDataPage(pageNum,pageSize,typeId);
        pageBean.setData(data);

        return pageBean;
    }

    @Override
    public Goods findGoodsDetail(int id) {
        return dao.findGoodsDetail(id);
    }

    @Override
    public GoodsType findGoodsType(int typeid) {
        return dao.findGoodsType(typeid);
    }
}
